<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" ></meta>
    <title>详细内容</title>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css" type="text/css">
    <%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <script type="text/javascript" src="../assets/js/echarts.js"></script>
    <link href="../assets/css/bootstrap-datetimepicker.css" type="text/css">
    <script src="../assets/js/bootstrap-datetimepicker.min.js"></script>
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="../assets/css/bootstrapDatepickr-1.0.0.css">
    <script src="../assets/js/bootstrapDatepickr-1.0.0.min.js"></script>
    <%--<link rel="stylesheet" href="${frames}/css/lib/dataTables.bootstrap.css" type="text/css">--%>
    <%--<link rel="stylesheet" href="${frames}/css/paginate.css" type="text/css">--%>
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <%--<link rel="stylesheet" href="${frames}/css/table.css" type="text/css">--%>
    <%--<link rel="stylesheet" href="${frames}/css/qulitity.css" type="text/css" type="text/css">--%>
    <script src="${frames}/Chronic/laydate/laydate.js"></script>
    <script src="${assets}/js/views/bpAbnormal.js"></script>
    <link rel="stylesheet" href="../assets/css/views/modules/_common.scss">
    <link rel="stylesheet" href="${assets}/css/views/department/departmentMgr.css">
    <style>
        span{
            font:15px/33px 微软雅黑;
            display:inline-block;
        }
        body{
            height:auto;
        }
        h4{
            font:22px/34px 微软雅黑;
            color:black;
        }
        h3{
            font-family: MicrosoftYaHei;
            font-size: 20px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #2a3137;
        }
        .title{
            line-height:25px;
            margin-bottom: 5px;
            font-size:16px;
            color:#666666;
            margin-left:10px;
        }
        .title1{
            line-height:25px;
            font-size:16px;
            color:#666666;
            margin-left:10px;
            margin-top:5px;
        }
        .test{
            width:95%;
            overflow:hidden;
            margin-top:15px;
        }
        .test p{
            width:100%;
            line-height:100px;
            font-size:15px;
            text-align:center;
        }
        .dataTable{
            text-align:center;
        }
        .daterange i {
            position: absolute;
            bottom: 10px;
            right: 14px;
            top: auto;
            cursor: pointer;
        }
        .daterange {
            position: relative;
        }
        .container1{
            display:inline-block;
            width:100%;
        }
        .times{
            display:inline-block;
            width:150px;
        }
        .add{
            float: right;
            width: 100px;
            font-size: 16px;
            line-height: 25px;
        }
        .container1{
            margin-top:15px;
        }
        .first_news{
        }
        #example_paginate{
            text-align: center;
        }
        #tablepart #example tbody tr{
            height:50px;
            margin-bottom:15px;
        }
        #tablepart #example thead tr th{
            font:15px/40px '微软雅黑';
            border:none !important;
        }
        .dataTable{
            text-align:center;
        }
        #tablepart #example1 tbody tr td{
            border:none !important;
            font:15px/40px '微软雅黑';
        }
        table.dataTable td, table.dataTable th{
            font:15px/40px '微软雅黑';
        }
        #tablepart tbody tr{
            border-bottom:1px solid #d0d0d0;
        }
        .btn{
            background:#35acfd !important;
            margin:0 !important;
            padding:0 !important;
            width: 100px;
            font-size: 16px;
            line-height: 32px;
        }
        #example_wrapper .row:nth-child(3){
            margin-top:20px;
        }
        #testSelect{
            width: 160px;
            line-height: 33px;
            border-radius: 5px;
            border: solid 1px #d0d0d0;
            display:inline-block;
            float:left;
        }
        img{
            max-width:100%;
            height:auto;
        }
        .bootstrapDatepickr-cal{
            top:160px !important;
        }
        a{
            text-decoration:none;
        }
        .page_nav li{
            list-style:none !important;
        }
        .page_nav li span{
            margin:0 !important;
        }
        .wrap #tablepart{
            margin-top:0px !important;
        }
        thead tr{
            background:#e6e6e6;
        }
        input{
            width:100%;
            line-height: 32px;
            border-radius: 5px;
            border: solid 1px #d0d0d0;
        }
        #tablepart tr th{
            width:24%;
        }
        #tablepart tr th:nth-child(1){
            width:4%;
        }
        td,th{
            font-family: MicrosoftYaHei;
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            line-height: 40px;
            letter-spacing: 0px;
            color: #999999;
            border-bottom:1px solid #e6e6e6;
            text-align:center;
        }
        input[type=checkbox] {
            width:20px;
            height:20px;
            -webkit-appearance: none;
            border-radius:5px;
            border:1px solid #9e9e9e;
        }
        input[type=checkbox]:checked{
            background-image: url('../assets/images/radio.png');
            background-size:100% 100%;
            border:none
        }
        .check_id{
            display:block !important
        }
        .dataTables_empty{
            line-height:30px;
        }
    </style>
</head>
<body>
<div>
    <%@ include file="../../breadline.jsp" %>
</div>
<div class="wrap">
    <div id="main" class="content">
        <div style="width:99%;overflow:hidden;background-color: #ffffff;box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.05);">
            <div style="margin-left:19px;width:97%;margin-top:20px;">
                <div class="first_news">
                    <div>
                        <div>
                            <h3 style="display:inline-block;">检查项目</h3>
                        </div>
                        <div class="container1" class="row">
                            <span style="display:inline-block;text-align:center;float:left;width:71px;"> 时间</span>
                            <div style="display:inline-block;float:left;">
                                <div>
                                    <div class="times">
                                        <div id="PrevTime" class="input-group date form_date" style="width: 100%"  data-date-format="yyyy-mm-dd">
                                            <input id="beginDate" type="text" class="lay-date" placeholder="  开始日期" readonly>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <button type="button" class="btn btn-info" onclick="search();" style="margin-left:30px !important;">
                                <img src="../assets/images/search.png" alt="" style="width:18px;vertical-align: middle;"> 搜索
                            </button>
                        </div>
                        <div style="width:400px;float:right;">
                            <button type="button" class="btn btn-info add" onclick="toUpdateTest()"  style="margin-right:20px !important">
                                <img src="../assets/images/revise.png" alt="" style="width:14px;vertical-align: middle;">&nbsp;&nbsp;修改
                            </button>
                            <button type="button" class="btn btn-info add" onclick="delet()"  style="margin-right:20px !important">
                                删除
                            </button>
                            <button type="button" class="btn btn-info add" onclick="toAddTest()" style="margin-right:20px !important">
                                <img src="../assets/images/add.png" alt="" style="width:14px;vertical-align: middle;">&nbsp;&nbsp;添加
                            </button>
                        </div>
                        <div id="tablepart">
                            <table id="example" class="display" cellspacing="10" width="100%">
                                <thead>
                                    <tr style="bordr:none !important;cursor:auto !important">
                                        <th>&nbsp;&nbsp;</th>
                                        <th>序号</th>
                                        <th style="width:1%"></th>
                                        <th>项目</th>
                                        <th>结果</th>
                                        <th>检查时间</th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    // boot时间选择器插件
    $(document).ready(function() {
        initLayDate('#beginDate');
    });
    var table;
    // 获取当前idcard
    var query = window.location.search;
    var url = query.split('?')[1].split('&')[0].split('=')[1]
    var diseasesType = query.split('?')[1].split('&')[1].split('=')[1]
    var type = query.split('?')[1].split('&')[2].split('=')[1]
    //获取ID
    var idCard = '${URL_TESTPROJECT_CHECKINFO}?idCard='+url
    function search(){
        refreshTable()
    }
    function toAddTest(){
        let that = this;
        // 弹窗 添加
        window.parent.showNewModelIframe('${URL_TESTPROJECT_TOADDCHECK}?idCard='+ url + '&diseasesType='+diseasesType+'&type='+type,800,450);
    }
    function toUpdateTest(){
        let that = this;
        var checkedArray = []
        var input = $('.check_id')
        for( var a = 0; a < input.length; a++ ){
            if( input[a].checked ){
                checkedArray.push(input[a])
            }
        }
        if( checkedArray.length != 1 ){
            alert('请勾选至少一项数据')
            return
        }else{
            let type = checkedArray[0].parentNode.childNodes[1].innerText
            if( type != 1 ){
                window.parent.showNewModelIframe('${URL_COMMON_TOTIPS}?title='+'该记录由医院同步,不能进行操作',300,200)
                return
            }
            // 弹窗 修改
            var td = checkedArray[0].parentNode.parentNode.childNodes;
            var checkProject = encodeURI(td[2].innerText)
            var checkResult = encodeURI(td[3].innerText)
            var checkTime = td[4].innerText
            var id = td[1].innerText
            window.parent.showNewModelIframe('${URL_TESTPROJECT_TOUPDATECHECK}?idCard=' + url + '&checkProject=' +checkProject
                + '&checkResult='+checkResult+'&checkTime='+checkTime + '&id='+ id + '&diseasesType='+diseasesType+'&type='+type,800,450);
        }
    }
    function delet(){
        var checkedArray = []
        var input = $('.check_id')
        for( var a = 0; a < input.length; a++ ){
            if( input[a].checked ){
                checkedArray.push(input[a])
            }
        }
        if( checkedArray.length != 1 ){
            alert('请勾选至少一项数据')
            return
        }else{
            var td = checkedArray[0].parentNode.parentNode.childNodes;
            var id = td[2].firstChild.innerText;
            $.ajax({
                url:'${URL_TESTPROJECT_DELETECHECK}',
                data:{
                    id : id
                },
                dataType:'json',
                type:"post",
                success:function(data){
                    if( data.success ){
                        parent.showSrc(window.location.href)
                    }
                }
            })
        }
    }
    var ListNum = 0;
    var bb = 0;
    var arr2 = [];
    var arr1 = [];
    function initTable() {
        table = $('#example').DataTable({
            "dom": "<'row'<'col-xs-2'l><'#mytool.col-xs-10'><'col-xs-6'f>r>" +
            "t" +
            "<'row'<''i><''p>>",
            "bFilter": false,//去掉搜索框
            "bAutoWidth": true, //自适应宽度
            "info": false,
            "bSort": false,
            "sPaginationType" : "full_numbers",
            "ordering": false,//是否允许Datatables开启排序
            "bProcessing" : true,
            "bServerSide" : true,
            "searching" : false, //去掉搜索框方法一
            'lengthChange' : false,
            "oPaginate":false,
            "lengthMenu": [10],
            "sAjaxSource":idCard,
            "sAjaxDataProp": "list",//查询后，返回的集合
            "fnServerData": function ( sSource, aoData, fnCallback ) {  //查询条件
                aoData.push(
                    {
                        "name": "checkTime",
                        "value": $('#beginDate').val()
                    }
                ),
                    $.ajax({
                        "dataType": 'json',
                        "url": sSource,
                        "type":'post',
                        "data": aoData,
                        "success":function(resp){
                            if( ListNum == 0 ){
                                bb = 1
                            }
                            var arr3 = []
                            for ( var a = 0; a < resp.data.iTotalDisplayRecords; a++ ){
                                arr3.push(a+1)
                            }
                            var arr1 = arr3.slice((bb-1)*10,bb*10);
                            for( var a = 0 ; a < arr1.length; a++ ){
                                resp.data.list[a].oldNumber = arr1[a]
                            }
                            fnCallback(resp.data)
                            var alis = $('.pagination li')
                            var lisa = alis.slice(1,alis.length-1)
                            for( var a = 0; a < lisa.length; a++ ){
                                $(lisa[a]).on('click',function(){
                                    bb = $(this).find('a').text()
                                })
                            }
                            $(alis[0]).on('click',function(){
                                if( bb != 0 ){
                                    bb --;
                                }
                            })
                            $(alis[alis.length-1]).on('click',function(){
                                if( bb < lisa.length ){
                                    bb++;
                                }
                            })
                            ListNum++;
                        }
                    });
            },
            "aoColumns" : [ {
                "targets": 0,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                     $(nTd).html('<input class="check_id" type="checkbox">'+'<span style="display:none;">'+ oData.type +'</span>')
                }
            },{
                "mDataProp" : "oldNumber"
            },{
                "targets": 2,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    $(nTd).html('<span style="display:none">'+oData.id+'</span>')
                }
            },{
                "mDataProp" : "checkProject"
            },{
                "mDataProp" : "checkResult"
            },{
                "targets": 5,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    $(nTd).text(oData.checkTime)
                }
            }],
            "oLanguage": {//插件的汉化
                "sLengthMenu": "32",
                "sZeroRecords" : "抱歉， 没有找到",
                "sInfoEmpty" : "没有数据",
                "sInfoFiltered" : "(从 _MAX_ 条数据中检索)",
                "oPaginate" : {
                    "sFirst" : "",
                    "sPrevious" : "<b>上一页<b>",
                    "sLast" : "",
                    "sNext" : "<i>下一页</i>"
                },
                "sZeroRecords" : "没有检索到数据",
                "sProcessing" : "<img src='' />",
                "sSearch" : "搜索"
            }
        } );
    }
    initTable()
</script>
</body>
</html>
